﻿Public Class search
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim txt_keyword As String = CType(Session.Item("txt_keyword"), String)
        Dim ddl_keyword As String = CType(Session.Item("ddl_keyword"), String)
        GridView1.Visible = False
        GridView2.Visible = False
        If ddl_keyword = "Events" Then
            GridView2.Visible = True

            Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="";"
            Dim sql As String = "SELECT event_name, event_location, event_description, event_postcode, event_date_time FROM Events WHERE (event_postcode = '" & txt_keyword & "') OR (event_location = '" & txt_keyword & "')"
            Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("SingerProfileConStr").ConnectionString)
            Dim dataadapter As New OleDb.OleDbDataAdapter(sql, conn)
            Dim ds As New DataSet()
            conn.Open()
            dataadapter.Fill(ds, "Events")
            conn.Close()
            GridView2.DataSource = ds
            GridView2.DataBind()
            If GridView2.Rows.Count < 1 Then
                lbl_vld_data.Text = " * No Records Found "
            End If
        ElseIf ddl_keyword = "Albums" Then
            GridView1.Visible = True

            Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="";"
            Dim sql1 As String = "SELECT Cover_Picture, Album_Name, Release_year, ID FROM Albums WHERE (Album_Name = '" & txt_keyword & "') OR (Release_year = '" & txt_keyword & "')"
            Dim conn1 As OleDb.OleDbConnection = New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("SingerProfileConStr").ConnectionString)
            Dim dataadapter1 As New OleDb.OleDbDataAdapter(sql1, conn1)
            Dim ds1 As New DataSet()
            conn1.Open()
            dataadapter1.Fill(ds1, "Albums")
            conn1.Close()
            GridView1.DataSource = ds1
            GridView1.DataBind()
            If GridView1.Rows.Count < 1 Then
                lbl_vld_data.Text = " * No Records Found "
            End If

        End If
    End Sub
End Class